import VueRouter from "vue-router";
import Vue from "vue";
import AI from '../views/AI.vue'
import MultiDialogue from "@/views/MultiDialogue.vue";
import AISelectModel from "@/views/AISelectModel.vue";

Vue.use(VueRouter);

/*
这段代码的主要功能是通过重写VueRouter.prototype.push方法，使其在导航失败时不会抛出异常，而是返回错误对象。
这在实际开发中可以帮助开发者更好地处理导航失败的情况，避免因未处理的错误导致程序崩溃。
*/
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};

const routes = [
  { path: '/ai', name: 'ai', component: AI },
  { path: '/multidialogue', name: 'multidialogue', component: MultiDialogue },
  { path: '/aiSelectModel', name: 'ai-select-model', component: AISelectModel }
]

const router = new VueRouter({
  mode: "hash",
  routes,
});


export default router
